package org.wheel.plugins.toolkit.sql.render;

import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import org.wheel.plugins.toolkit.sql.core.AbstractParamRender;

import java.util.LinkedHashMap;

public class MybatisHashRender extends AbstractParamRender  {


    public MybatisHashRender(LinkedHashMap<String, Object> paramMap) {
        super(paramMap);
    }

    @Override
    public String render(String sql) {
        return ReUtil.replaceAll(sql, ":(\\w+)", m -> {
            String key = m.group(1);
            return StrUtil.format("#\\{{}\\}", key) ;
        });
    }

}
